package cn.doit.scala.day03

import cn.doit.scala.day03.beans.User

/**
 * @DATE 2021/12/27/17:21
 * @Author MDK
 * @Version 2021.2.2
 * */
object C13_Sorted04 {
  def main(args: Array[String]): Unit = {
    val  list = List (1, 34 , 32 , 12 , 20 ,44 ,27)
    val  arr = Array[String]("java" , "scala" , "hive" , "spark" , "flink")
    val map = Map[String , Int]("peiqi"->4 , "aqiaozhi"->2 , "baji"->34)

    // ">"降序  "<"升序
    val res = list.sortWith((x1, x2) => x1 < x2)
    val res2 = arr.sortWith((str1, str2) => str1 < str2)
    println(res)
    println(res2.toList)

    val  users = List[User](User(1,"lny",18) , User(3,"liuyan",44) , User(2,"tianhao",18),User(4,"荣波",18))
    val res3 = users.sortWith((user1, user2) => user1.id < user2.id)
    res3.foreach(println)
  }
}
